package com.zhentao.service.impl;

import com.zhentao.mapper.RoleMapper;
import com.zhentao.pojo.Role;
import com.zhentao.service.RoleService;
import io.seata.spring.annotation.GlobalTransactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
//@Transactional//开启事务
public class RoleServiceImpl implements RoleService {

    @Autowired
    private RoleMapper roleMapper;

    @GlobalTransactional(rollbackFor = Exception.class)
    @Override
    public Integer add(Role role) {
        int num = roleMapper.insert(role);

        //稍后我要模拟一个错误
        int a=1/0;
        return num;
    }
}
